package U2;

import java.util.Arrays;

public class Test3 {
	   public int findShortest(int[] A, int n) {
	        if(A == null || n < 2) return 0;
	        int []temp = new int [n];
	        for(int i = 0;i < n;i ++) {
	        	temp[i] = A[i];
	        }
	        Arrays.sort(temp);
	        int l = 0,r = n - 1;
	        while (l < n  && A[l] == temp[l]) {
				l ++;
			}
	        while (r > l && A[r] == temp[r]) {
				r --;
			}
	        return r - l + 1;
	    }

}
